package com.ydm.fire_fighting_web.modules.index.web;

import com.ydm.fire_fighting_web.entity.index.Equipments;
import com.ydm.fire_fighting_web.entity.index.EventInformation;
import com.ydm.fire_fighting_web.entity.index.FireFightingEquipment;
import com.ydm.fire_fighting_web.modules.index.api.IndexControllerApi;
import com.ydm.fire_fighting_web.modules.index.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/index")
public class IndexController implements IndexControllerApi {
    @Autowired
    private IndexService indexService;
    @Override
    @PostMapping("/findAllEquipment")
    public Equipments findAllEquipment() {
        Equipments allEquipment = indexService.findAllEquipment();
        return allEquipment;
    }

    @Override
    @GetMapping("/findTOPTenEquipment")
    public List<FireFightingEquipment> findTOPTenEquipment(String LastTime) {
        List<FireFightingEquipment> equipmentList = indexService.findTOPTenEquipment(LastTime);
        return equipmentList;
    }

    @Override
    @GetMapping("/findTenEventInformation")
    public List<EventInformation> findTenEventInformation(String LastTime) {
        List<EventInformation> eventInformations = indexService.findTenEventInformation(LastTime);
        return eventInformations;
    }

    @Override
    @GetMapping("/findAllBadEquipment")
    public List<FireFightingEquipment> findAllBadEquipment() {
        List<FireFightingEquipment> equipmentList =  indexService.findAllBadEquipment();
        return equipmentList;
    }
}
